package ustc.xiaoyang.karl.string;

/**
 * 151.反转字符串中的单词 medium
 */
public class ReverseTheWordsInTheString151 {
    public static String reverseWords(String s) {
        String[] strings = s.trim().split("\\s+");
        StringBuffer sb = new StringBuffer();
        for (int i = strings.length-1; i >= 0; i--) {
            sb.append(strings[i]);
            if(i != 0) sb.append(" ");
        }
        return sb.toString();
    }

}
